/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-12-10     xu       the first version
 */
#ifndef APPLICATIONS_KVDB_H_
#define APPLICATIONS_KVDB_H_

#include <flashdb.h>
#include <rtthread.h>
#include <stdint.h>
#include <time.h>

struct kvdb {
    struct fdb_kvdb db;
    rt_mutex_t mutex;
    const char* part;
    void* user_data;
};

typedef struct kvdb* kvdb_t;

kvdb_t kvdb_open(const char* part);
void kvdb_close(kvdb_t kvdb);
rt_bool_t kvdb_show(kvdb_t kvdb);

rt_bool_t kvdb_inited(kvdb_t kvdb);
rt_bool_t kvdb_del(kvdb_t kvdb, const char* key);
rt_bool_t kvdb_set(kvdb_t kvdb, const char* key, const uint8_t* value, size_t value_len);
rt_bool_t kvdb_get(kvdb_t kvdb, const char* key, uint8_t* value, size_t* value_len);

#endif /* APPLICATIONS_KVDB_H_ */